package com.white.databasesbackup.dao.impl;

import com.white.databasesbackup.dao.DatabasesBackupConfigureDao;
import com.white.databasesbackup.entity.DatabasesBackupConfigure;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 实现
 * </p>
 *
 * @author huangzy
 * @since 2022/5/6
 */
@Component
public class DatabasesBackupConfigureDaoImpl implements DatabasesBackupConfigureDao {

    @Resource
    private JdbcTemplate jdbcTemplate;

    @Override
    public List<DatabasesBackupConfigure> list() {
        return jdbcTemplate.query("SELECT * FROM databases_backup_configure",new BeanPropertyRowMapper<>(DatabasesBackupConfigure.class));
    }

    @Override
    public DatabasesBackupConfigure getById(Integer id) {
        return jdbcTemplate.queryForObject("SELECT * FROM databases_backup_configure WHERE id = ?",new BeanPropertyRowMapper<>(DatabasesBackupConfigure.class),id);
    }
}
